// 扁平化数组
export function flattenArray(arr, prop = "child") {
  const result = [];
  let index = 0;
  function flatten(arr) {
    for (const item of arr) {
      item.index = index;
      result.push(item);
      index++;
      if (item[prop]) {
        flatten(item[prop]);
      }
    }
  }
  flatten(arr);
  return result;
}
